package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	var bCh = make(chan int)	
	var cCh = make(chan int)

	//go func() {
	//	bCh <- 10
	//}()
	
	go func() {
		for{
			cCh <- rand.Intn(10)
			time.Sleep(time.Second)

			select {
			case vb := <-bCh:
				fmt.Printf("消费b %v \n", vb)
			}
		}
	}()
	
	go func() {
		for{
			select {
			case vc := <- cCh:
				fmt.Printf("消费c %v \n", vc)
			}

			bCh <- rand.Intn(10)
			time.Sleep(time.Second)
		}
	}()
	time.Sleep(10 * time.Second)
	fmt.Println("end")
}
